package com.itsc.dao;

import java.util.List;

import org.hibernate.Query;

import com.itsc.entities.CenterPerson;
import com.itsc.util.page.Page;

public class CenterPersonDao extends BaseDao<CenterPerson>{
	@SuppressWarnings("unchecked")
	public List<CenterPerson> search(String name, Page page) {
		name = name == null ? "" : name;
		String hql = "from CenterPerson where cp_name like ? or cp_department like ?";
		Query query = getSession().createQuery(hql);
		query.setString(0, "%" + name + "%");
		query.setString(1, "%" + name + "%");
		if (page != null) {
			query.setFirstResult(page.getBeginIndex());
			query.setMaxResults(page.getPageSize());
		}
		return query.list();
	}
}
